<? 
include('../../src/inst.conf.php');



?>


<!-- JavaScript -->
<script src="./js/jquery.min.js"></script>
<script src="./js/jqueryui.min.js"></script>
<script src="./js/jquery.cookies.js"></script>
<script src="./js/jquery.pjax.js"></script>
<script src="./js/formalize.min.js"></script>
<script src="./js/jquery.metadata.js"></script>
<script src="./js/jquery.validate.js"></script>
<script src="./js/jquery.checkboxes.js"></script>
<script src="./js/jquery.chosen.js"></script>
<script src="./js/jquery.fileinput.js"></script>
<script src="./js/jquery.datatables.js"></script>
<script src="./js/jquery.sourcerer.js"></script>
<script src="./js/jquery.tipsy.js"></script>
<script src="./js/jquery.calendar.js"></script>
<script src="./js/jquery.inputtags.min.js"></script>
<script src="./js/jquery.wymeditor.js"></script>
<script src="./js/jquery.livequery.js"></script>
<script src="./js/jquery.flot.min.js"></script>
<script src="./js/jquery.watch.js"></script>
<script src="./js/application.js"></script>
<script type="text/javascript">
$('#modalcontainer').html('<div id="edit_ll" class="box"></div>');
var modal = $("#edit_ll");
var tr = "";
$('a[href="#edit_ll"]').live('click', function(){
$('#edit_ll').html('<div class="box-header"><h1>Bewerk leerling</h1></div><div class="box-content"><form name="edit_ll_form" id="edit_ll_form" action="javascript:;"><div class="column-left"><p><input type="hidden" id="id" name="id"><span class="icon tick valid"></span></p><p><input type="text" id="Voornaam" name="Voornaam" placeholder="Voornaam" class="{validate: {required:true}}"><span class="icon tick valid"></span></p><p><input type="text" id="tussen" name="tussen" placeholder="Tussenvoegsel" class="{validate: {required:false}}"><span class="icon tick valid"></span></p><p><input type="text" id="Achternaam" name="Achternaam" placeholder="Achternaam" class="{validate: {required:true}}"><span class="icon tick valid"></span></p></div><div class="column-right"><p><input type="text" id="Gebruikersnaam" name="Gebruikersnaam" placeholder="Gebruikersnaam" class="{validate: {required:true}}"><span class="icon tick valid"></span></p><p><input type="text" id="Email" name="Email" placeholder="E-Mail adres" class="{validate: {required:true}}"><span class="icon tick valid"></span></p><p> <input type="checkbox" name="disabled" id="disabled" value="1" /> <label for="disabled">Uitgeschakeld</label></p></div><div class="clear"></div><div class="action_bar"><input type="submit" class="button red" value="Submit" id="submit_edit_ll" name="submit_edit_ll"><a href="#" onclick="$(\'#overlay\').hide();"class="close button">Close window</a></div></form></div>');
	$('#overlay').show();
	$('#edit_ll').show();
	tr=$(this).parent().parent();
	$(modal).find('[id="id"]').val($(tr).find("td:nth-child(1)").html());
	$(modal).find('[id="Voornaam"]').val($(tr).find("td:nth-child(3)").html());
	$(modal).find('[id="tussen"]').val($(tr).find("td:nth-child(4)").html());
	$(modal).find('[id="Achternaam"]').val($(tr).find("td:nth-child(5)").html());
	$(modal).find('[id="Gebruikersnaam"]').val($(tr).find("td:nth-child(6)").html());
	$(modal).find('[id="Email"]').val($(tr).find("td:nth-child(7)").html());
	if($(tr).hasClass('disabled'))
	{
		$(modal).find('[id="disabled"]').attr("checked", "checked");
	}
	$('input[type=checkbox],input[type=radio]').prettyCheckboxes();
});
$("#submit_edit_ll").live('click', function(){
	var table=$('#leerlingen_datatable').dataTable();
	$(tr).find("td:nth-child(3)").html($(modal).find('[id="Voornaam"]').val());
	$(tr).find("td:nth-child(4)").html($(modal).find('[id="tussen"]').val());
	$(tr).find("td:nth-child(5)").html($(modal).find('[id="Achternaam"]').val());
	$(tr).find("td:nth-child(6)").html($(modal).find('[id="Gebruikersnaam"]').val());
	$(tr).find("td:nth-child(7)").html($(modal).find('[id="Email"]').val());
	if($(modal).find('[id="disabled"]').is(':checked'))
	{
		$(tr).addClass("disabled");
	}else{
		$(tr).removeClass("disabled");
	}
	$('#overlay').hide();
	table.fnDestroy();
	var table=$('#leerlingen_datatable').dataTable();
	//var send_data = $("#edit_ll_form").serializeArray();
	//var url = "./src/edit.ll.php";
	//$.post( url, send_data ,function( data ) {});
});
$('a[href="#remove"]').live('click', function(){
	//<!---$('span#total').html($('span#total').html()-1);---!>
	
	
	//var url = "./src/remove.ll.php";
	//$.post( url, "id="+$(this).parent().parent().find('td:nth-child(1)').html() ,function( data ) {})
	var table=$('#leerlingen_datatable').dataTable();
	table.fnDeleteRow($(this).parent().parent());
});
</script>
<div class="box">
  <div class="box-header">
    <h1>Leerlingen</h1>
  </div>

  <table id="leerlingen_datatable" class="datatable">
    <thead>
      <tr>
        <th width="25px">ID</th>
        <th width="50px">LL NR</th>
        <th>Voornaam</th>
        <th></th>
        <th>Achternaam</th>
        <th>Gebruikersnaam</th>
        <th>Email</th>
        <th width="200px">Acties</th>
      </tr>
    </thead>
    <tbody>
    <? 
    // haal alle docenten uit de database
    $query = mysql_query("SELECT * FROM  `LEERLING`")or die(mysql_error());
    while($data = mysql_fetch_assoc($query)){
		if(isset($data['DISABLED']) && $data['DISABLED'] == 1){echo"<tr class=\"disabled\">";}else{echo"<tr>";}
    	echo"  <td>".$data['LEERLING_ID']."</td>";
    	echo"  <td>".$data['LEERLINGNUMMER']."</td>";
    	echo"  <td>".utf8_encode($data['VOORNAAM'])."</td>";
    	echo"  <td>".utf8_encode($data['TUSSENVOEGSEL'])."</td>";
    	echo"  <td>".utf8_encode($data['ACHTERNAAM'])."</td>";
    	echo"  <td>".utf8_encode($data['GEBRUIKERSNAAM'])."</td>";
    	echo"  <td>".utf8_encode($data['E_MAIL_ADRES'])."</td>";
    	echo"  <td>";
    	echo"  	<a href=\"#edit_ll\" class=\"button plain\">Wijzig</a>";
    	echo"  	<a href=\"#remove\" class=\"button plain red\">Verwijder</a>";
    	echo"  </td>";
    	echo"</tr>";	
    }
    
    ?>
    </tbody>
  </table>
</div> 